<template>
  <div class="cloud_shop_template">
    <div class="my_income" v-if="is_shop_owner && otherInfo.my_reward_status">
      <div class="headTop">
        <div class="headTop_l"></div>
        <div class="headTop_txt">我的收益</div>
      </div>
      <div class="total_revenue" @click="to_reward">
        <div class="total_revenue_txt">累计总收益（元）</div>
        <div class="total_revenue_b">
          <div class="num">{{ otherInfo.sum_all_reward }}</div>
          <div class="todayNum">今日收益 {{ otherInfo.today_all_reward }}</div>
        </div>
        <div class="revenueList">
          <div class="revenueBlock">
            <div class="txt" v-if="cloud_basic_info">{{ cloud_basic_info.self_reward_name }}</div>
            <div class="num">{{ otherInfo.sum_order_reward }}</div>
            <div class="today">今日 {{ otherInfo.today_order_reward }}</div>
          </div>
          <div class="revenueBlock">
            <div class="txt">销售活动奖励</div>
            <div class="num">{{ otherInfo.sum_activity_reward }}</div>
          </div>
        </div>
      </div>
      <div class="total_revenue" @click="to_cloud_shop_reward_center">
        <div class="total_revenue_des">
          <img class="total_revenue_des_img" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/cloud_shop%2Fcenter%402x.png" alt="" />
          <div class="total_revenue_des_txt">奖励中心</div>
        </div>
        <div class="revenueList">
          <div class="revenueBlock revenueBlock_b">
            <div class="txt">即将开始</div>
            <div class="num">{{ otherInfo.expect_activity_count }}</div>
          </div>
          <div class="revenueBlock revenueBlock_b">
            <div class="txt">火热进行中</div>
            <div class="num">{{ otherInfo.running_activity_count }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="salesBox" v-if="otherInfo && otherInfo.month_percent > 0">
      <div class="headTop">
        <div class="headTop_l"></div>
        <div class="headTop_txt monthBox">当前月薪比例:{{ otherInfo.month_percent }}%</div>
      </div>
    </div>
    <div class="salesBox" v-if="is_shop_owner && otherInfo && otherInfo.my_sale_status">
      <div class="mysales" @click="to_mysales">
        <div class="headTop">
          <div class="headTop_l"></div>
          <div class="headTop_txt">我的销售</div>
        </div>
        <div class="mysales_r">查看全部<i class="iconfont icon-icon_more11"></i></div>
      </div>
      <div class="mysales" @click="to_brandSales">
        <div class="mysales_f">
          <img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/cloud_shop%2Fbrandsales.png" alt="" />
          <div class="mysales_f_txt">品牌销售榜</div>
        </div>
        <div class="mysales_r">查看详情<i class="iconfont icon-icon_more11"></i></div>
      </div>
    </div>
    <div class="customerBox" @click="toCustomersMy" v-if="is_shop_owner && otherInfo && otherInfo.my_customer_status">
      <div class="mycustomer">
        <div class="headTop">
          <div class="headTop_l"></div>
          <div class="headTop_txt">我的顾客</div>
        </div>
      </div>
      <div class="customerDetail">
        <div class="customerDetail_lis">
          <div class="customerDetail_lis_top">20天内顾客<i class="iconfont icon-icon_more11"></i></div>
          <div class="count">{{ otherInfo.new_customer_count }}</div>
          <div class="today">
            今日<span class="is_color">+{{ otherInfo.today_customer_count }}</span>
          </div>
        </div>
        <div class="customerDetail_lis">
          <div class="customerDetail_lis_top">全部有效顾客<i class="iconfont icon-icon_more11"></i></div>
          <div class="count">{{ otherInfo.usable_customer_count }}</div>
          <div class="today">
            今日<span class="is_color">+{{ otherInfo.today_usable_customer_count }}</span>
          </div>
        </div>
        <div class="customerDetail_lis">
          <div class="customerDetail_lis_top">顾客成交订单<i class="iconfont icon-icon_more11"></i></div>
          <div class="count">{{ otherInfo.sum_order_count }}</div>
          <div class="today">
            今日<span class="is_color">+{{ otherInfo.today_order_count }}</span>
          </div>
        </div>
      </div>
    </div>
    <div class="myService" v-if="cloud_shop_plugin_list && cloud_shop_plugin_list.length > 0">
      <div class="plugin-items-icon">
        <div class="extension_plate">
          <h1>
            <div class="spare"></div>
            我的服务
          </h1>
          <ul class="box">
            <li v-show="child.url" v-for="(child, i) in cloud_shop_plugin_list" :key="i" @click="pluginGoto(child)">
              <!-- :class="child.class" :style="child.image_url|setBGImage"-->
              <i class="iconfont" :style="{ backgroundImage: `url('${child.image}')` }"></i>
              <span>{{ child.title }}</span>
              <div class="Badge" v-show="child.value > 0">{{ child.value > 99 ? "99+" : child.value }}</div>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  props: ["otherInfo", "is_shop_owner", "cloud_shop_plugin_list", "guide_show_status"],
  data() {
    return {
      cloud_basic_info: null
    };
  },
  mounted() {
    this.cloud_basic_info = JSON.parse(localStorage.getItem("yz_basic_info")).plugin_setting.cloud_shop;
  },
  methods: {
    toCustomersMy() {
      this.$router.push(this.fun.getUrl("customersMy", {}));
    },
    to_cloud_shop_reward_center() {
      this.$router.push(this.fun.getUrl("cloud_shop_reward_center", {}));
    },
    to_brandSales() {
      this.$router.push(this.fun.getUrl("brandSales", {}));
    },
    to_mysales() {
      this.$router.push(this.fun.getUrl("mysales", {}));
    },
    to_reward() {
      this.$router.push(this.fun.getUrl("baseRewardTemplate", {}, { date_time: 1, api: "plugin.cloud-shop.frontend.reward.index" }));
    },
    pluginGoto(item) {
      if (item.name == "cloud_shop_customer_service") {
        window.location.href = item.url;
        return;
      }
      if (item.name == "cloud_shop_coupon_center") {
        console.log(item.url);
        this.$router.push(this.fun.getUrl("couponStore", {}, {}));
        return;
      }
      if (item.name == "cloud_shop_suggest") {
        console.log(item.url);
        let parts = item.url.split("/");
        let parameter = parts[1];
        console.log(parameter, "ddddddddddd");
        this.$router.push(this.fun.getUrl("DiyForm", { id: parameter }, {}));
        return;
      }
      if (item.name == "m-erweima") {
        this.$emit("show_poster");
        return;
      }
      this.$router.push(this.fun.getUrl(item.url, {}, {}));
    }
  },
  computed: {}
};
</script>
<style lang="scss" scoped>
.headTop {
  display: flex;
  align-items: center;
  .headTop_l {
    width: 0.19rem;
    height: 0.88rem;
    background: #f15353;
  }
  .headTop_txt {
    font-size: 0.88rem;
    color: #333333;
    font-weight: bold;
    margin-left: 0.31rem;
  }
}
.customerBox {
  border-radius: 0.47rem;
  padding: 0.63rem 0.75rem;
  margin: 0 10px;
  margin-top: 0.63rem;
  background: #ffffff;
  .mycustomer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border-bottom: 1px solid #e9e9e9;
    padding-bottom: 0.63rem;
    margin-bottom: 0.63rem;
  }
  .customerDetail {
    display: flex;
    justify-content: space-between;
    .customerDetail_lis {
      width: 6.44rem;
      background: #f9f9f9;
      padding: 0.63rem 0.5rem;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: flex-start;
      border-radius: 0.47rem;
      .customerDetail_lis_top {
        display: flex;
        align-items: center;
        font-size: 0.75rem;
        color: #808080;
        .icon-icon_more11 {
          color: #aaaab3;
          font-size: 0.75rem;
        }
      }
      .today {
        font-size: 0.75rem;
        color: #808080;
        .is_color {
          color: #f15353;
        }
      }
      .count {
        font-weight: bold;
        font-size: 1.13rem;
        color: #333333;
        line-height: 1.2rem;
        margin: 0.5rem 0;
      }
    }
  }
}
.salesBox {
  border-radius: 0.47rem;
  padding: 0.63rem 0.75rem;
  margin: 0 10px;
  margin-top: 0.63rem;
  background: #ffffff;
  .mysales {
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-sizing: border-box;
    border-bottom: 1px solid #e9e9e9;
    padding-bottom: 0.63rem;
    margin-bottom: 0.63rem;
    .mysales_f {
      display: flex;
      align-items: center;
      img {
        width: 1.25rem;
        height: 1.25rem;
        margin: 0;
        margin-right: 0.63rem;
      }
      .mysales_f_txt {
        font-weight: 500;
        font-size: 0.81rem;
        color: #333333;
      }
    }
    .mysales_r {
      display: flex;
      align-items: center;
      font-size: 0.75rem;
      color: #808080;
      .icon-icon_more11 {
        color: #aaaab3;
        margin-left: 0.5rem;
        font-size: 0.85rem;
      }
    }
  }
  .mysales:last-child {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
  }
}

.my_income {
  margin: 0 10px;
  background: #ffffff;
  border-radius: 0.47rem;
  padding: 0.63rem 0.94rem;
  box-sizing: border-box;
  .monthBox {
    font-size: 0.88rem;
    color: #333333;
    text-align: left;
    font-weight: bold;
  }
  .total_revenue {
    margin-top: 1.28rem;
    .total_revenue_des {
      display: flex;
      align-items: center;
      .total_revenue_des_img {
        width: 1.25rem;
        height: 1.25rem;
        margin: 0;
      }
      .total_revenue_des_txt {
        font-size: 0.88rem;
        color: #333333;
        margin-left: 0.25rem;
        font-weight: bold;
        line-height: 0.95rem;
      }
    }
    .total_revenue_txt {
      font-size: 0.75rem;
      color: #6e6e79;
      margin-bottom: 0.66rem;
      text-align: left;
    }
    .total_revenue_b {
      display: flex;
      align-items: flex-end;
      .num {
        font-size: 1.75rem;
        color: #333333;
        line-height: 1.75rem;
        font-weight: bold;
      }
      .todayNum {
        font-size: 0.75rem;
        color: #f15353;
        margin-left: 0.47rem;
      }
    }
    .revenueList {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 0.5rem;
      .revenueBlock {
        flex: 1;
        background: #f9f9f9;
        border-radius: 0.47rem;
        padding: 0.63rem 0.5rem;
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        justify-content: space-around;
        height: 4.72rem;
        .txt {
          font-size: 0.75rem;
          color: #808080;
        }
        .num {
          font-size: 1.13rem;
          color: #403f3f;
          font-weight: bold;
        }
        .today {
          font-size: 0.75rem;
          color: #f15353;
        }
      }
      .revenueBlock:last-child {
        margin-left: 0.63rem;
      }
      .revenueBlock_b {
        height: 3.72rem;
      }
    }
  }
}
.myService {
  margin: 0 10px;
  background: #ffffff;
  margin-top: 0.63rem;
  .plugin-items-icon {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    font-size: 12px;
    position: relative;

    .iconfont {
      display: inline-block;
      margin: 0 auto 5px auto;
      width: 1.75rem;
      height: 1.75rem;
      background-size: 100%;
    }

    .Badge {
      height: 0.875rem;
      line-height: 0.875rem;
      font-size: 0.75rem;
      color: #fff;
      padding: 0 0.25rem;
      border-radius: 1rem;
      background-color: #f15353;
      position: absolute;
      top: 0px;
      left: 55%;
    }
  }
  /* 模板二 插件数据 */
  .extension_plate {
    margin-bottom: 0.625rem;
    background: #fff;

    h1 {
      font-size: 16px;
      height: 2.5rem;
      line-height: 2.5rem;
      text-align: left;
      padding: 0 0.875rem;
      display: flex;

      .spare {
        width: 0.25rem;
        height: 1rem;
        border-radius: 0.0625rem;
        background-color: #f15353;
        margin-top: 0.75rem;
        margin-right: 0.375rem;
      }
    }

    .box {
      display: flex;
      flex-wrap: wrap;
      padding: 0.625rem 0;

      li {
        width: 25%;
        margin-bottom: 0.625rem;
        position: relative;

        img {
          width: 1.75rem;
          margin: 0 auto;
          display: block;
        }

        span {
          font-size: 12px;
          line-height: 1.875rem;
          display: block;
          color: #666;
        }

        .Badge {
          height: 0.875rem;
          line-height: 0.875rem;
          font-size: 0.75rem;
          color: #fff;
          padding: 0 0.25rem;
          border-radius: 1rem;
          background-color: #f15353;
          position: absolute;
          top: -5px;
          left: 55%;
        }
      }
    }
  } /* 模板二 插件数据 end */
}
</style>
